home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxcindex.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.8 KB  |  132 lines

  1. /* Copyright (C) 1995, 1996, 1997, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxcindex.h,v 1.2 2000/09/19 19:00:34 lpd Exp $ */
  20. /* Define the device color index type and macros */
  21.  
  22. #ifndef gxcindex_INCLUDED
  23. #  define gxcindex_INCLUDED
  24.  
  25. #include "gsbitops.h"        /* for sample_store macros */
  26.  
  27. /*
  28.  * Define the maximum number of components in a device color.
  29.  * The minimum value is 4, to handle CMYK; the maximum value is
  30.  * sizeof(gx_color_index) * 8, since for larger values, there aren't enough
  31.  * bits in a gx_color_index to have even 1 bit per component.
  32.  */
  33. #define GX_DEVICE_COLOR_MAX_COMPONENTS 6
  34.  
  35. /*
  36.  * We might change gx_color_index to a pointer or a structure in the
  37.  * future.  These disabled options help us assess how much disruption
  38.  * such a change might cause.
  39.  */
  40. /*#define TEST_CINDEX_POINTER*/
  41. /*#define TEST_CINDEX_STRUCT*/
  42.  
  43. /*
  44.  * Internally, a (pure) device color is represented by opaque values of
  45.  * type gx_color_index, which are tied to the specific device.  The driver
  46.  * maps between these values and RGB[alpha] or CMYK values.  In this way,
  47.  * the driver can convert RGB values to its most natural color representation,
  48.  * and have the graphics library cache the result.
  49.  */
  50.  
  51. #ifdef TEST_CINDEX_STRUCT
  52.  
  53. /* Define the type for device color index (pixel value) data. */
  54. typedef struct { ulong value[2]; } gx_color_index_data;
  55.  
  56. #else  /* !TEST_CINDEX_STRUCT */
  57.  
  58. /* Define the type for device color index (pixel value) data. */
  59. typedef ulong gx_color_index_data;
  60.  
  61. #endif /* (!)TEST_CINDEX_STRUCT */
  62.  
  63. #ifdef TEST_CINDEX_POINTER
  64.  
  65. /* Define the type for device color indices (pixel values). */
  66. typedef gx_color_index_data * gx_color_index;
  67. #define arch_sizeof_color_index arch_sizeof_ptr
  68.  
  69. extern const gx_color_index_data gx_no_color_index_data;
  70. #define gx_no_color_index_values (&gx_no_color_index_data)
  71. #define gx_no_color_index (&gx_no_color_index_data)
  72.  
  73. #else  /* !TEST_CINDEX_POINTER */
  74.  
  75. /* Define the type for device color indices (pixel values). */
  76. typedef gx_color_index_data gx_color_index;
  77. #define arch_sizeof_color_index arch_sizeof_long
  78.  
  79. /* Define the 'transparent' color index. */
  80. #define gx_no_color_index_value (-1)    /* no cast -> can be used in #if */
  81.  
  82. /* The SGI C compiler provided with Irix 5.2 gives error messages */
  83. /* if we use the proper definition of gx_no_color_index: */
  84. /*#define gx_no_color_index ((gx_color_index)gx_no_color_index_value) */
  85. /* Instead, we must spell out the typedef: */
  86. #define gx_no_color_index ((unsigned long)gx_no_color_index_value)
  87.  
  88. #endif /* (!)TEST_CINDEX_POINTER */
  89.  
  90. /*
  91.  * Define macros for accumulating a scan line of a colored image.
  92.  * The usage is as follows:
  93.  *    DECLARE_LINE_ACCUM(line, bpp, xo);
  94.  *    for ( x = xo; x < xe; ++x ) {
  95.  *        << compute color at x >>
  96.  *          LINE_ACCUM(color, bpp);
  97.  *      }
  98.  * This code must be enclosed in { }, since DECLARE_LINE_ACCUM declares
  99.  * variables.  Supported values of bpp are 1, 2, 4, 8, 12, 16, 24, 32.
  100.  *
  101.  * Note that DECLARE_LINE_ACCUM declares the variables l_dptr, l_dbyte, and
  102.  * l_dbit.  Other code in the loop may use these variables.
  103.  */
  104. #define DECLARE_LINE_ACCUM(line, bpp, xo)\
  105.     sample_store_declare_setup(l_dptr, l_dbit, l_dbyte, line, 0, bpp)
  106. #define LINE_ACCUM(color, bpp)\
  107.     sample_store_next32(color, l_dptr, l_dbit, bpp, l_dbyte)
  108. #define LINE_ACCUM_SKIP(bpp)\
  109.     sample_store_skip_next(l_dptr, l_dbit, bpp, l_dbyte)
  110. #define LINE_ACCUM_STORE(bpp)\
  111.     sample_store_flush(l_dptr, l_dbit, bpp, l_dbyte)
  112. /*
  113.  * Declare additional macros for accumulating a scan line with copying
  114.  * to a device.  Note that DECLARE_LINE_ACCUM_COPY also declares l_xprev.
  115.  * LINE_ACCUM_COPY is called after the accumulation loop.
  116.  */
  117. #define DECLARE_LINE_ACCUM_COPY(line, bpp, xo)\
  118.     DECLARE_LINE_ACCUM(line, bpp, xo);\
  119.     int l_xprev = (xo)
  120. #define LINE_ACCUM_COPY(dev, line, bpp, xo, xe, raster, y)\
  121.     if ( (xe) > l_xprev ) {\
  122.         int code;\
  123.         LINE_ACCUM_STORE(bpp);\
  124.         code = (*dev_proc(dev, copy_color))\
  125.           (dev, line, l_xprev - (xo), raster,\
  126.            gx_no_bitmap_id, l_xprev, y, (xe) - l_xprev, 1);\
  127.         if ( code < 0 )\
  128.           return code;\
  129.     }
  130.  
  131. #endif /* gxcindex_INCLUDED */
  132.